#include <stdio.h>
#include <grp.h>
#include <stddef.h>

void read_groups(void);
void pr_group(const struct group *);

struct aa {
    char aa_bb[10];
    int aa_cc;
};

int main(void)
{
    read_groups();
    return 0;
}

void read_groups()
{
    struct group * gp;
    setgrent();
    while ((gp = getgrent()) != NULL)
    {
        pr_group(gp);
        putchar('\n');
    }
    endgrent();
}

void pr_group(const struct group * gp)
{
    char ** gr_mem = gp->gr_mem;

    printf("struct group: %s\n", gp->gr_name);
    printf("\tgr_passwd: %s\n", gp->gr_passwd);
    printf("\tgr_gid: %d\n", gp->gr_gid);
    printf("\t members:\n");
    while (*gr_mem != NULL)
    {
        printf("\t\tmember: %s\n", *gr_mem);
        ++gr_mem;
    }

}
